/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package config;

import java.util.Collections;
import java.util.Map;
import share.PGHelper;

/**
 *
 * @author Salm
 */
public class CFFindEggsNPC {
    
    private CFFindEggsNPC() {}
    public static CFFindEggsNPC parse(Map<String, Object> json)
    {
        String jsonData = PGHelper.getJSONParser().toJson(json);
        CFFindEggsNPC feNPC = PGHelper.getJSONParser().fromJson(jsonData, CFFindEggsNPC.class);
        feNPC.init();
        
        return feNPC;
    }
    
    private void init()
    {
        eggs = Collections.unmodifiableMap(eggs);
        cooldown *= 1000L;
    }
    
    private int unlockLevel;
    private long maxTime;
    private long cooldown;
    private long freeTime;
    private int price;
    private Map<Integer, Option> options;
    private Map<String, Egg> eggs;
    private Map<String, Item> items;

    public int getUnlockLevel() {
        return unlockLevel;
    }

    public long getMaxTime() {
        return maxTime;
    }

    public long getCooldown() {
        return cooldown;
    }

    public long getFreeTime() {
        return freeTime;
    }

    public int getPrice() {
        return price;
    }

    public Map<String, Egg> eggs() {
        return eggs;
    }

    public Map<Integer, Option> options() {
        return options;
    }

    public Map<String, Item> items() {
        return items;
    }
    
    public int randomNOfEggs(int op)
    {
        Option option = this.options.get(op);
        return PGHelper.rand(option.minFind, option.maxFind) * option.round;
    }
    
    public static class Egg
    {
        private Egg() {}
        
        private int unlockLevel;
        private double minGold;
        private double maxGold;
        private double minCoin;
        private double maxCoin;
        private double minFindTime;
        private double maxFindTime;

        public int getUnlockLevel() {
            return unlockLevel;
        }

        public double getMinGold() {
            return minGold;
        }

        public double getMaxGold() {
            return maxGold;
        }

        public double getMinCoin() {
            return minCoin;
        }

        public double getMaxCoin() {
            return maxCoin;
        }

        public double getMinFindTime() {
            return minFindTime;
        }

        public double getMaxFindTime() {
            return maxFindTime;
        }
    }
    
    public static class Option
    {
        private int minFind;
        private int maxFind;
        private int round;
    }
    
    public static class Item
    {
        private CFPaymentType payType;
        private int price;
        private long time;

        public CFPaymentType getPayType() {
            return payType;
        }

        public int getPrice() {
            return price;
        }

        public long getTime() {
            return time * 1000L;
        }
    }
}
